\(\int (c+d \tan (e+f x)) (A+B \tan (e+f x)+C \tan ^2(e+f x)) \, dx\) [53]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 31, antiderivative size = 73 \[ \int (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=(A c-c C-B d) x-\frac {(B c+(A-C) d) \log (\cos (e+f x))}{f}+\frac {B d \tan (e+f x)}{f}+\frac {C (c+d \tan (e+f x))^2}{2 d f} \]

[Out]

(A*c-B*d-C*c)*x-(B*c+(A-C)*d)*ln(cos(f*x+e))/f+B*d*tan(f*x+e)/f+1/2*C*(c+d*tan(f*x+e))^2/d/f

Rubi [A] (verified)

Time = 0.06 (sec) , antiderivative size = 73, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.097, Rules used = {3711, 3606, 3556} \[ \int (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=-\frac {(d (A-C)+B c) \log (\cos (e+f x))}{f}+x (A c-B d-c C)+\frac {B d \tan (e+f x)}{f}+\frac {C (c+d \tan (e+f x))^2}{2 d f} \]

[In]

Int[(c + d*Tan[e + f*x])*(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2),x]

[Out]

(A*c - c*C - B*d)*x - ((B*c + (A - C)*d)*Log[Cos[e + f*x]])/f + (B*d*Tan[e + f*x])/f + (C*(c + d*Tan[e + f*x])
^2)/(2*d*f)

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3606

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c - b
*d)*x, x] + (Dist[b*c + a*d, Int[Tan[e + f*x], x], x] + Simp[b*d*(Tan[e + f*x]/f), x]) /; FreeQ[{a, b, c, d, e
, f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]

Rule 3711

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (
f_.)*(x_)]^2), x_Symbol] :> Simp[C*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Int[(a + b*Tan[e + f*x])
^m*Simp[A - C + B*Tan[e + f*x], x], x] /; FreeQ[{a, b, e, f, A, B, C, m}, x] && NeQ[A*b^2 - a*b*B + a^2*C, 0]
&&  !LeQ[m, -1]

Rubi steps \begin{align*} \text {integral}& = \frac {C (c+d \tan (e+f x))^2}{2 d f}+\int (A-C+B \tan (e+f x)) (c+d \tan (e+f x)) \, dx \\ & = (A c-c C-B d) x+\frac {B d \tan (e+f x)}{f}+\frac {C (c+d \tan (e+f x))^2}{2 d f}+(B c+(A-C) d) \int \tan (e+f x) \, dx \\ & = (A c-c C-B d) x-\frac {(B c+(A-C) d) \log (\cos (e+f x))}{f}+\frac {B d \tan (e+f x)}{f}+\frac {C (c+d \tan (e+f x))^2}{2 d f} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.52 (sec) , antiderivative size = 76, normalized size of antiderivative = 1.04 \[ \int (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {2 A c f x-2 (c C+B d) \arctan (\tan (e+f x))-2 (B c+(A-C) d) \log (\cos (e+f x))+2 (c C+B d) \tan (e+f x)+C d \tan ^2(e+f x)}{2 f} \]

[In]

Integrate[(c + d*Tan[e + f*x])*(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2),x]

[Out]

(2*A*c*f*x - 2*(c*C + B*d)*ArcTan[Tan[e + f*x]] - 2*(B*c + (A - C)*d)*Log[Cos[e + f*x]] + 2*(c*C + B*d)*Tan[e
+ f*x] + C*d*Tan[e + f*x]^2)/(2*f)

Maple [A] (verified)

Time = 0.05 (sec) , antiderivative size = 75, normalized size of antiderivative = 1.03

method result size
norman \(\left (A c -B d -C c \right ) x +\frac {\left (B d +C c \right ) \tan \left (f x +e \right )}{f}+\frac {C d \tan \left (f x +e \right )^{2}}{2 f}+\frac {\left (A d +B c -C d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f}\) \(75\)
derivativedivides \(\frac {\frac {C \tan \left (f x +e \right )^{2} d}{2}+B \tan \left (f x +e \right ) d +C \tan \left (f x +e \right ) c +\frac {\left (A d +B c -C d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A c -B d -C c \right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) \(80\)
default \(\frac {\frac {C \tan \left (f x +e \right )^{2} d}{2}+B \tan \left (f x +e \right ) d +C \tan \left (f x +e \right ) c +\frac {\left (A d +B c -C d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A c -B d -C c \right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) \(80\)
parts \(A c x +\frac {\left (A d +B c \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f}+\frac {\left (B d +C c \right ) \left (\tan \left (f x +e \right )-\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}+\frac {C d \left (\frac {\tan \left (f x +e \right )^{2}}{2}-\frac {\ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}\right )}{f}\) \(86\)
parallelrisch \(\frac {2 A c f x -2 B d f x -2 C c f x +C \tan \left (f x +e \right )^{2} d +A \ln \left (1+\tan \left (f x +e \right )^{2}\right ) d +B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) c +2 B \tan \left (f x +e \right ) d -C \ln \left (1+\tan \left (f x +e \right )^{2}\right ) d +2 C \tan \left (f x +e \right ) c}{2 f}\) \(99\)
risch \(\frac {2 i A d e}{f}-i C d x +i A d x +A c x -B d x -C c x -\frac {2 i C d e}{f}+i B c x +\frac {2 i B c e}{f}+\frac {2 i \left (-i C d \,{\mathrm e}^{2 i \left (f x +e \right )}+B d \,{\mathrm e}^{2 i \left (f x +e \right )}+C c \,{\mathrm e}^{2 i \left (f x +e \right )}+B d +C c \right )}{f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )^{2}}-\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) A d}{f}-\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) B c}{f}+\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) C d}{f}\) \(181\)

[In]

int((c+d*tan(f*x+e))*(A+B*tan(f*x+e)+C*tan(f*x+e)^2),x,method=_RETURNVERBOSE)

[Out]

(A*c-B*d-C*c)*x+(B*d+C*c)/f*tan(f*x+e)+1/2*C*d/f*tan(f*x+e)^2+1/2*(A*d+B*c-C*d)/f*ln(1+tan(f*x+e)^2)

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 74, normalized size of antiderivative = 1.01 \[ \int (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {C d \tan \left (f x + e\right )^{2} + 2 \, {\left ({\left (A - C\right )} c - B d\right )} f x - {\left (B c + {\left (A - C\right )} d\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right ) + 2 \, {\left (C c + B d\right )} \tan \left (f x + e\right )}{2 \, f} \]

[In]

integrate((c+d*tan(f*x+e))*(A+B*tan(f*x+e)+C*tan(f*x+e)^2),x, algorithm="fricas")

[Out]

1/2*(C*d*tan(f*x + e)^2 + 2*((A - C)*c - B*d)*f*x - (B*c + (A - C)*d)*log(1/(tan(f*x + e)^2 + 1)) + 2*(C*c + B
*d)*tan(f*x + e))/f

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 131 vs. \(2 (60) = 120\).

Time = 0.12 (sec) , antiderivative size = 131, normalized size of antiderivative = 1.79 \[ \int (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\begin {cases} A c x + \frac {A d \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac {B c \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} - B d x + \frac {B d \tan {\left (e + f x \right )}}{f} - C c x + \frac {C c \tan {\left (e + f x \right )}}{f} - \frac {C d \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac {C d \tan ^{2}{\left (e + f x \right )}}{2 f} & \text {for}\: f \neq 0 \\x \left (c + d \tan {\left (e \right )}\right ) \left (A + B \tan {\left (e \right )} + C \tan ^{2}{\left (e \right )}\right ) & \text {otherwise} \end {cases} \]

[In]

integrate((c+d*tan(f*x+e))*(A+B*tan(f*x+e)+C*tan(f*x+e)**2),x)

[Out]

Piecewise((A*c*x + A*d*log(tan(e + f*x)**2 + 1)/(2*f) + B*c*log(tan(e + f*x)**2 + 1)/(2*f) - B*d*x + B*d*tan(e
 + f*x)/f - C*c*x + C*c*tan(e + f*x)/f - C*d*log(tan(e + f*x)**2 + 1)/(2*f) + C*d*tan(e + f*x)**2/(2*f), Ne(f,
 0)), (x*(c + d*tan(e))*(A + B*tan(e) + C*tan(e)**2), True))

Maxima [A] (verification not implemented)

none

Time = 0.39 (sec) , antiderivative size = 74, normalized size of antiderivative = 1.01 \[ \int (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {C d \tan \left (f x + e\right )^{2} + 2 \, {\left ({\left (A - C\right )} c - B d\right )} {\left (f x + e\right )} + {\left (B c + {\left (A - C\right )} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right ) + 2 \, {\left (C c + B d\right )} \tan \left (f x + e\right )}{2 \, f} \]

[In]

integrate((c+d*tan(f*x+e))*(A+B*tan(f*x+e)+C*tan(f*x+e)^2),x, algorithm="maxima")

[Out]

1/2*(C*d*tan(f*x + e)^2 + 2*((A - C)*c - B*d)*(f*x + e) + (B*c + (A - C)*d)*log(tan(f*x + e)^2 + 1) + 2*(C*c +
 B*d)*tan(f*x + e))/f

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 761 vs. \(2 (71) = 142\).

Time = 0.78 (sec) , antiderivative size = 761, normalized size of antiderivative = 10.42 \[ \int (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\text {Too large to display} \]

[In]

integrate((c+d*tan(f*x+e))*(A+B*tan(f*x+e)+C*tan(f*x+e)^2),x, algorithm="giac")

[Out]

1/2*(2*A*c*f*x*tan(f*x)^2*tan(e)^2 - 2*C*c*f*x*tan(f*x)^2*tan(e)^2 - 2*B*d*f*x*tan(f*x)^2*tan(e)^2 - B*c*log(4
*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)^2*t
an(e)^2 - A*d*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2
 + 1))*tan(f*x)^2*tan(e)^2 + C*d*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + ta
n(f*x)^2 + tan(e)^2 + 1))*tan(f*x)^2*tan(e)^2 - 4*A*c*f*x*tan(f*x)*tan(e) + 4*C*c*f*x*tan(f*x)*tan(e) + 4*B*d*
f*x*tan(f*x)*tan(e) + C*d*tan(f*x)^2*tan(e)^2 + 2*B*c*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan
(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)*tan(e) + 2*A*d*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)
*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)*tan(e) - 2*C*d*log(4*(tan(f*x)^2*tan(
e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)*tan(e) - 2*C*c*tan(f
*x)^2*tan(e) - 2*B*d*tan(f*x)^2*tan(e) - 2*C*c*tan(f*x)*tan(e)^2 - 2*B*d*tan(f*x)*tan(e)^2 + 2*A*c*f*x - 2*C*c
*f*x - 2*B*d*f*x + C*d*tan(f*x)^2 + C*d*tan(e)^2 - B*c*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(ta
n(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1)) - A*d*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan
(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1)) + C*d*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(
f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1)) + 2*C*c*tan(f*x) + 2*B*d*tan(f*x) + 2*C*c*tan(e) + 2*B*d*tan(e)
+ C*d)/(f*tan(f*x)^2*tan(e)^2 - 2*f*tan(f*x)*tan(e) + f)

Mupad [B] (verification not implemented)

Time = 8.70 (sec) , antiderivative size = 75, normalized size of antiderivative = 1.03 \[ \int (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (B\,d+C\,c\right )}{f}-x\,\left (B\,d-A\,c+C\,c\right )+\frac {\ln \left ({\mathrm {tan}\left (e+f\,x\right )}^2+1\right )\,\left (\frac {A\,d}{2}+\frac {B\,c}{2}-\frac {C\,d}{2}\right )}{f}+\frac {C\,d\,{\mathrm {tan}\left (e+f\,x\right )}^2}{2\,f} \]

[In]

int((c + d*tan(e + f*x))*(A + B*tan(e + f*x) + C*tan(e + f*x)^2),x)

[Out]

(tan(e + f*x)*(B*d + C*c))/f - x*(B*d - A*c + C*c) + (log(tan(e + f*x)^2 + 1)*((A*d)/2 + (B*c)/2 - (C*d)/2))/f
 + (C*d*tan(e + f*x)^2)/(2*f)